<?php
function getConnet(){
       $hostname="127.0.0.1";
        $username="root";
        $password="123456";
        $database="mysql123";

        $connet=mysqli_connect($hostname, $username, $password, $database);
        
        if($connet){
            return $connet;
        }else{
            return false;
        }
        
        /**
         * type 该link，orfalse
         */
}

function actSelceSQL($sql){
    /**
     * 该方法用于sql的查询
     */
    
    $dataset=array();
    $connet=getConnet();
    mysqli_set_charset($connet, "utf-8");
    if($connet){
        $result= mysqli_query($connet, $sql);
       $row= mysqli_fetch_array($result);
          $index=0;
          //用一个数组$dataset便利存储结果集的每行内容
               while($row){
                  $dataset[$index]=$row;
                $row= mysqli_fetch_array($result);
                $index++;
               }
    }else{
        
    }
    //mysqli_close 关闭数据库连接
            mysqli_close($connet);
            return $dataset;
}

function actUpdateSQL($sql){
     $dataset= array();
             $connet= getConnect();
            //设置连接的字符集
            mysqli_set_charset($connet, "utf-8");
            if(connet){
                 $result=mysqli_query($connet, $sql);
                 if($result){
                     return true;
                 }else{
                     return false;
                 }
                 
            }
             //mysqli_close 关闭数据库连接
            mysqli_close($connet);
            return $dataset;
            
                   
}



?>